#include "GMSyncTimer.h"
#include "Factory.h"
#include "TimerMS.h"

#include <iostream>

GMSyncTimer::GMSyncTimer()
{

}

void GMSyncTimer::Execute()
{

}

bool GMSyncTimer::Read(SocketMessage* sm)
{
	int time = 0;
	sm->ReadInt(&time);
	TheTimerMS::Instance()->SetTimeMS(time);
	std::cout << "recv time in MS: " << time << std::endl;

	//SDL_Delay(1000);
	//TheTimer::Instance()->UpdateTime();
	//std::cout << "recv time after delay: " << TheTimer::Instance()->GetTime() << std::endl;
	return true;
}

void GMSyncTimer::Write(SocketMessage* sm)
{
	sm->WriteString("GMSyncTimer");
	int timeMS = TheTimerMS::Instance()->GetTimeMS();
	sm->WriteInt(timeMS);
	std::cout << "sent time in MS: " << timeMS << std::endl;
}